from abc import ABC, abstractmethod
from typing import Optional


class ServoInterface(ABC):
    """舵机控制接口基类"""

    @abstractmethod
    def set_position(self, position: int, speed: int = 1000) -> bool:
        """设置舵机位置"""
        pass

    @abstractmethod
    def get_position(self) -> Optional[int]:
        """获取舵机位置"""
        pass

    @abstractmethod
    def update_position(self) -> None:
        """更新舵机位置"""
        pass

    @abstractmethod
    def set_deviation(self, new_deviation: int = 0) -> None:
        """设置舵机偏移量"""
        pass

    @abstractmethod
    def emergency_stop(self) -> None:
        """紧急停止"""
        pass
